/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * AddModule.java
 *
 * Created on 26-Mar-2011, 14:20:29
 */
package staffclientejb;

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.EJB;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import studenttrack.session.StaffSessionRemote;

/**
 *
 * @author 025013
 */
public class AddModule extends javax.swing.JFrame {
    @EJB
    private static StaffSessionRemote staffSession;


    /** Creates new form AddModule */
    public AddModule() {
        initComponents();
        this.setVisible(true);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        modCode = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        credits = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        modName = new javax.swing.JTextField();
        confirmButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setFont(new java.awt.Font("DejaVu LGC Sans", 1, 18));
        jLabel1.setText("Add Module");

        jLabel2.setFont(new java.awt.Font("DejaVu LGC Sans", 1, 13));
        jLabel2.setText("Module Code:");

        jLabel3.setFont(new java.awt.Font("DejaVu LGC Sans", 1, 13));
        jLabel3.setText("Credit Rating:");

        jLabel4.setFont(new java.awt.Font("DejaVu LGC Sans", 1, 13));
        jLabel4.setText("Name:");

        confirmButton.setFont(new java.awt.Font("DejaVu LGC Sans", 0, 18));
        confirmButton.setText("Confirm");
        confirmButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                confirmButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(33, 33, 33)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel3))
                .addGap(80, 80, 80)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(modName, javax.swing.GroupLayout.DEFAULT_SIZE, 175, Short.MAX_VALUE)
                    .addComponent(credits, javax.swing.GroupLayout.DEFAULT_SIZE, 175, Short.MAX_VALUE)
                    .addComponent(modCode, javax.swing.GroupLayout.DEFAULT_SIZE, 175, Short.MAX_VALUE))
                .addGap(106, 106, 106))
            .addGroup(layout.createSequentialGroup()
                .addGap(186, 186, 186)
                .addComponent(jLabel1)
                .addContainerGap(191, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGap(168, 168, 168)
                .addComponent(confirmButton)
                .addContainerGap(246, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addComponent(jLabel1)
                .addGap(33, 33, 33)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel2)
                    .addComponent(modCode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(modName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3)
                    .addComponent(credits, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(41, 41, 41)
                .addComponent(confirmButton)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void confirmButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_confirmButtonActionPerformed
       // try {
            //ModuleInterface mi = (ModuleInterface) InitialContext.doLookup("java:global/Application/ModuleInterface");
            String moduleCode = modCode.getText();
            String moduleName = modName.getText();
            int creditWeighting = Integer.parseInt(credits.getText());
           // mi.setCode(moduleCode);
           // mi.setName(moduleName);
           // mi.setCreditWeighting(creditWeighting);
        //} catch (NamingException ex) {
          //  Logger.getLogger(AddModule.class.getName()).log(Level.SEVERE, null, ex);
        //}
        // Send the message to the server application
        /**  try {
        outToServer.writeBytes(moduleCode + "\n");
        outToServer.writeBytes(moduleName + "\n");
        outToServer.writeInt(creditRating);
        // Print response from server - close socket.
        System.out.println("FROM SERVER: " + inFromServer.readLine());
        clientSocket.close();
        } catch (IOException e) {
        System.out.println("IOException occured when trying to add module.");
        }*/
    }//GEN-LAST:event_confirmButtonActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new AddModule().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton confirmButton;
    private javax.swing.JTextField credits;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JTextField modCode;
    private javax.swing.JTextField modName;
    // End of variables declaration//GEN-END:variables
}
